<?php
if (!defined("__WD__")) exit("Wrong Connect");

if ( !function_exists("mailto") ) {
	function mailto($MAIL_FROM_NAME,$MAIL_FROM,$MAIL_TO,$MAIL_SUBJ,$body) {
	    $mailheaders = "Return-Path: <$MAIL_FROM> \r\n";
	    $mailheaders .= "From: =?utf-8?B?".base64_encode($MAIL_FROM_NAME)."?=  <{$MAIL_FROM}>\r\n";
	    $mailheaders .= "X-Mailer: JOYNET Interface\r\n";
	
	    $boundary = "--------" . uniqid("part");
	
	    $mailheaders .= "MIME-Version: 1.0\r\n";
	    $mailheaders .= "Content-Type: multipart/alternative; boundary=\"=_NextPart_$boundary\"";
	
	    $bodytext  = "This is a multi-part message in MIME format.\r\n\r\n";
	    $bodytext .= "--=_NextPart_$boundary\r\n";
	    $bodytext .= "Content-Type: text/plain; charset=utf-8\r\n";
	    $bodytext .= "Content-Transfer-Encoding: base64\r\n\r\n";
	    $bodytext .= @ereg_replace("(.{80})","\\1\r\n",base64_encode(strip_tags($body))) . "\r\n\r\n";
	
	    $bodytext .= "--=_NextPart_$boundary\r\n";
	    $bodytext .= "Content-Type: text/html; charset=utf-8\r\n";
	    $bodytext .= "Content-Transfer-Encoding: base64\r\n\r\n";
	
	    $bodytext .= @ereg_replace("(.{80})","\\1\r\n",base64_encode(stripslashes($body)));
	    $bodytext .= "\r\n\r\n--=_NextPart_$boundary--\r\n";
	    $result = mail($MAIL_TO, '=?utf-8?B?' . base64_encode($MAIL_SUBJ) . '?=',$bodytext,$mailheaders);
	
	    return $result;
	}
}
function sendmail($name, $from, $to, $subject, $body, $html = 1, $charset = "utf-8" ) {
	
	$smtp_server	= "smtp.naver.com";	//enter your smtp server here
	$smtp_user		= "jsy5702";		//enter your smtp username here
	$smtp_passwd	= "jsy2629";
	
	if (!$smtp_sock = fsockopen("$smtp_server", 25)) die ("Couldn't open mail connection to $smtp_server! n");
	
	fputs($smtp_sock, "AUTH LOGINn");
	fputs($smtp_sock, base64_encode($smtp_user)."n");
	fputs($smtp_sock, base64_encode($smtp_passwd)."n");
	fputs($smtp_sock, "HELO $smtp_servern");
	fputs($smtp_sock, "VRFY $stmp_usern");
	fputs($smtp_sock, "MAIL FROM:$fromn");
	fputs($smtp_sock, "RCPT TO:$ton");
	fputs($smtp_sock, "DATAn");
	fputs($smtp_sock, "From: $name<$from>n");
	fputs($smtp_sock, "X-Mailer: miplusn");
	if ($html) fputs($smtp_sock, "Content-Type: text/html;");
	else fputs($smtp_sock, "Content-Type: text/plain;");
	fputs($smtp_sock, "charset=$charsern");
	fputs($smtp_sock, "MIME-Version: 1.0n");
	fputs($smtp_sock, "Subject: $subjectn");
	fputs($smtp_sock, "To: $ton");
	fputs($smtp_sock, "$body");
	fputs($smtp_sock, "n.nQUITn");
	fclose($smtp_sock);
	
	
}
